#QZXing库
OPTION(OPTION_RABBITIM_USE_QZXING "Use QZXing library" ON)
if(OPTION_RABBITIM_USE_QZXING)
    FIND_PACKAGE(QZXing)
    if(NOT QZXing_FOUND)
        return()
    endif()
endif()

PROJECT(QRCode)

file(RELATIVE_PATH PLUGIN_RELATIVE_DIR ${CMAKE_SOURCE_DIR}/Plugin ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT ANDROID)
    set(PLUGIN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/plugins/${PLUGIN_RELATIVE_DIR})
    set(PLUGIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/plugins/${PLUGIN_RELATIVE_DIR})
endif()

ADD_PLUGIN_TARGET(
    SOURCE_FILES
        CPluginQRCode.cpp
        FrmScanQRcode.cpp
        FrmScanQRcode.ui
    INCLUDE_DIRS $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Src>
    PRIVATE_LIBS RabbitIm QZXing
    OUTPUT_DIR ${PLUGIN_OUTPUT_DIR}
    INSTALL_DIR ${PLUGIN_INSTALL_DIR}
    )

if(BUILD_PLUGIN_APP)
    ADD_TARGET(
        NAME ${PROJECT_NAME}App
        ISEXE
        SOURCE_FILES main.cpp
        PRIVATE_LIBS ${PROJECT_NAME} RabbitIm QZXing
        INCLUDE_DIRS $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
        OUTPUT_DIR ${PLUGIN_OUTPUT_DIR}
        INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
endif()
